{% set vars = {'name': ""} %}
{% set vars = {'oper_state': ""} %}
{% set vars = {'in_packets': ""} %}
{% set vars = {'in_errors': ""} %}
{% set vars = {'in_discards': ""} %}
{% set vars = {'out_packets': ""} %}
{% set vars = {'out_errors': ""} %}
{% set vars = {'out_discards': ""} %}
{% if json_output -%}
------------------------------------------------------------------------------------------------
{{'%-15s'|format("Interface")}}{{'%-10s'|format("State")}}{{'%-10s'|format("RX_OK")}}{{'%-10s'|format("RX_ERR")}}{{'%-10s'|format("RX_DRP")}}{{'%-10s'|format("TX_OK")}}{{'%-10s'|format("TX_ERR")}}{{'%-10s'|format("TX_DRP")}}
------------------------------------------------------------------------------------------------
{% for key_json in json_output %}
{% set interface_list = json_output[key_json]["interface"] %}
{% for interface in interface_list %}
    {% for key in interface %}
        {% if "state" in key %}
            {% if vars.update({'name':interface[key]["name"]}) %}{% endif %}
            {% if interface[key]["oper-status"] =='DOWN' %}
               {% if vars.update({'oper_state':'D'}) %}{% endif %}
            {% else %}
               {% if vars.update({'oper_state':'U'}) %}{% endif %}
            {% endif %}
        {% endif %}
        {% if "counters" in interface["state"] %}
            {% if vars.update({'in_packets':interface["state"]["counters"]["in-pkts"]}) %}{% endif %}
            {% if vars.update({'in_errors':interface["state"]["counters"]["in-errors"]}) %}{% endif %}
            {% if vars.update({'in_discards':interface["state"]["counters"]["in-discards"]}) %}{% endif %}
            {% if vars.update({'out_packets':interface["state"]["counters"]["out-pkts"]}) %}{% endif %}
            {% if vars.update({'out_errors':interface["state"]["counters"]["out-errors"]}) %}{% endif %}
            {% if vars.update({'out_discards':interface["state"]["counters"]["out-discards"]}) %}{% endif %}
        {% endif %}
    {% endfor %}
{% if 'Ethernet' in vars.name %}
{{'%-15s'|format(vars.name)}}{{'%-10s'|format(vars.oper_state)}}{{'%-10s'|format(vars.in_packets)}}{{'%-10s'|format(vars.in_errors)}}{{'%-10s'|format(vars.in_discards)}}{{'%-10s'|format(vars.out_packets)}}{{'%-10s'|format(vars.out_errors)}}{{'%-10s'|format(vars.out_discards)}}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
